/**
 * Created by Administrator on 2017/4/19 0019.
 */



// 基于准备好的dom，初始化echarts实例
var myChart = echarts.init(document.getElementById('lineargradient-pie'));

var percent = 0.7;
var dataStyle = {
    normal: {
        label: {show:false},
        labelLine: {show:false}
    }
};
// 指定图表的配置项和数据
var option = {
    backgroundColor: 'rgba(0,0,0,0)',
    title: {
        text: (percent * 100) + '%',
        subtext: 'Mpa',
        x: 'center',
        y: '26%',
        textStyle: {
            color: '#596679',
            fontSize: 20,
            fontWeight: 'normal'
        },
        subtextStyle: {
            color: '#666',
            fontSize: 14
        }
    },

    series : [

        {
            name: 'main',
            type: 'pie',
            radius: [31, 39],
            hoverAnimation: false,
            label: {
                normal: {
                    show: false
                }
            },

            data: getData()
        }

    ]
};

function getData() {
    return [{
        value: percent,
        itemStyle:{
            normal:{
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                    offset: 0,
                    color: '#7388d7'
                }, {
                    offset: 1,
                    color: '#d12977'
                }])
            }
        }
    }, {
        value: 1 - percent,
        itemStyle: {
            normal: {
                color: 'transparent'
            }
        }
    }];
};


// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
